<template>
	<view class="wrap">
		<view v-if="isInit" v-cloak>
			<noRecord v-if="menuInfo.list.length == 0" :info="info" v-cloak></noRecord>
			<menuList v-else :menuInfo="menuInfo" @loadMore="addPage"></menuList>
		</view>
	</view>
</template>
<script>
import menuList from '@/wxcomponents/commonLayout/menuList.vue';
import noRecord from '@/wxcomponents/commonLayout/noRecord.vue';
import { getDictName, dectList } from '@/libs/common.js';
export default {
	data() {
		return {
			isInit: false,
			info: '没有申请记录!',
			menuInfo: {
				base: {
					menuProp: ['carType', 'plateNumbers', 'status'],
					tit: ['车辆型号', '车牌号', '状态'],
					class: 'threeCol',
					loadMore: true
				},
				list: []
			},
			pageParams: {
				pageNum: 1,
				pageSize: 20
			}
		};
	},
	onLoad() {
		this.getList();
	},
	methods: {
		//申请状态
		async getList(e) {
			let resp = await this.$http.post({
				url: '/oa/carApply/page',
				data: this.pageParams
			});
			let dictList = await dectList('dict_car_apply_status');

			if (resp.result.rows.length < this.pageParams.pageSize || resp.result.rows.length == 0) {
				this.menuInfo.base.loadMore = false;
			}
			resp.result.rows.forEach(async item => {
				item.detailType = 'detail';
				this.menuInfo.list.push({
					url: `applyDetail?data=${JSON.stringify(item)}`,
					carType: item.carType,
					plateNumbers: item.plateNumbers,
					status: await getDictName(dictList, item.applyStatus),
					data: item,
				});
			});
			this.isInit = true;
		},
		// 加载下一页
		addPage() {
			this.pageParams.pageNum++;
			this.getList();
		}
	},
	components: { menuList, noRecord }
};
</script>

<style lang="scss" scoped>
[v-cloak] {
	display: none !important;
}
</style>
